﻿using JzSport.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace JzSport.WebApp.Init
{
    public partial class AddActivityCategory : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void _ctlBtnSubmit_Click(object sender, EventArgs e)
        {
            // 创建活动类别
            BaseDataService bdService = new BaseDataService();
            BaseDataSummary summary = bdService.GetLatestSummary("ActivityCategory").Data;
            summary.IsEnable = false;
            bdService.UpdateSammary(summary);

            BaseDataSummary newSummary = new BaseDataSummary();

            newSummary.Id = new Guid("{8BA5A071-E2D2-4F98-98F6-9BFC2FAED468}");
            newSummary.Code = "ActivityCategory";
            newSummary.Caption = "活动类别";
            newSummary.Changeset = summary.Changeset + 1;
            newSummary.IsEnable = true;
            bdService.SaveSummary(newSummary);

            //羽毛球，足球，篮球，网球，排球，台球，气排球，乒乓球，自行车，户外拓展，攀岩
            string[] acCodes = new string[]{
                    "AC012",
                    "AC001",
                    "AC002",
                    "AC003",
                    "AC013",
                    "AC007",
                    "AC014",
                    "AC009",
                    "AC004",
                    "AC005",
                    "AC006",
                    "AC008",
                    "AC010",
                    "AC011",
                    "AC999"
                };
            string[] acCaptions = new string[]{
                    "推荐",
                    "羽毛球",
                    "足球",
                    "篮球",
                    "健身房",
                    "气排球",
                    "慢跑",
                    "自行车",
                    "网球",
                    "排球",
                    "台球",
                    "乒乓球",
                    "户外拓展",
                    "攀岩",
                    "其他"
                };
            for (int index = 0; index < acCodes.Length; index++)
            {
                BaseDataItem item = new BaseDataItem();
                item.Id = Guid.NewGuid();
                item.Caption = acCaptions[index];
                item.Code = acCodes[index];
                item.SummaryId = newSummary.Id;
                item.Order = index;
                bdService.SaveItem(item);
                Response.Write(string.Format("<b>创建活动类别,code:{0},caption:{1}</b><br/>", acCodes[index], acCaptions[index]));
            }
        }
    }
}